<?php
include('./php/connect.php');
include('./php/query_diagioi.php');
include('./php/functions.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Mật độ phân bố dân cư Việt Nam</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="shortcut icon" href="icons/title.ico" type="image/x-icon" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <link rel="stylesheet" href="css/mycss.css" rel="stylesheet" media="all"/>
        <script type="text/javascript" src="scripts/maps_vn.js" ></script>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=vi"></script>
        <script type="text/javascript">
            google.maps.event.addDomListener(window, 'load', function () {
                var polygons = [];
                var cities = [];
                var name_cities = [];
                var population_cities = [];
<?php
$tongso = array();
$i = 0;
while ($row = mysql_fetch_array($rs_tongso)) {
    $tongso[$i++] = $row["tongso"];
    echo "name_cities.push('" . $row['Ten'] . "');";
    echo "population_cities.push('" . $row['tongso'] . "');";
    echo "cities.push(new google.maps.LatLng(" . $row['Lat'] . "," . $row['Lng'] . "));";
}

while ($row = mysql_fetch_array($rs)) {
    $st = $row["polygon"];
    $st = str_replace("POLYGON((", "", $st);
    $st = str_replace("))", "", $st);
    $array = explode(",", $st);
    $size = count($array);
    echo "var positions = [];";
    for ($i = 0; $i < $size; $i++) {
        $s = explode(" ", $array[$i]);
        $st1 = $s[1] . "," . $s[0];
        echo "positions.push(new google.maps.LatLng(" . $st1 . "));";
    }
    $color = getColor($row['Dan_So'], $tongso);
    echo "var polygon = new google.maps.Polygon({
                                paths: positions,
                                strokeColor :\"" . $color . "\",
                                strokeOpacity : 1,
                                strokeWeight : 2,
                                fillColor :\"" . $color . "\",
                                fillOpacity : 0.6
                            });
                            polygons.push(polygon);";
}
?>
                show(polygons, cities, name_cities, population_cities);
            });
        </script>
    </head>
    <body>
        <h1>Địa chính Việt Nam</h1>
        <br/>
        <input type="button" value="Trang chủ" id="index" onclick="location.href='index.php'" />&nbsp;
        <br/>
        <br/>
        <div id="map"></div>
    </body>
</html>
